package algoritm;
import java.util.ArrayList;
import java.util.Collections;
public class sort {


	public static void main(String[] args) {
		int num=10;
		ArrayList<Integer> list = new ArrayList<Integer>(num);
		
		for(int i=0;i<num;i++){
			list.add(i);
		}
		Collections.shuffle(list);
		System.out.println(list);
		long start = System.nanoTime();
		buble(list,num);
		long end = System.nanoTime();
		long traceTime = end-start;

		System.out.println(traceTime);
		System.out.println(list);
	}
	
	
	
	public static void buble(ArrayList<Integer> list,int num) {
		int t=0;
		boolean flag = false;
		for(int i=0;i<num-1 && !flag;i++){
			t=0;
			for(int j=0;j<num-i-1;j++){
				if(list.get(j)>list.get(j+1)){
					int tmp=list.get(j);
					list.set(j,list.get(j+1));
					list.set(j+1, tmp);
					t++;
					}
				}
			if (t==0) flag=true;System.out.println(list);
			}
		
		}

	}
